In the video domain pixels are typically represented by one or several bytes of data. For example, in the default format used for MPEG video encoding, a pixel is stored by saving its luminance component as a byte. The chrominance part of the pixel is stored as two bytes, but these values are shared for several pixels at the same time. If the luminance part is considered, for example, the byte consists of 8 individual bits, and is referred to as a “bit-plane”.
A dominant part of MPEG video encoding consists of motion estimation, which can be computed very efficiently when carried out on a bit-plane basis. The “sum-of-absolute-differences” operation, when executed on a bit-plane basis, involves an exclusive-or operation only, followed by counting the bits of the result value, the latter often being supported as a single instruction in a DSP processor. During a pre-processing step, the bit-plane has to be extracted from the video stream. Such a pre-processing step may involve, for example, extracting a particular bit from each byte in a 32 bit value containing four packed bytes. To perform the bit-plane extraction operation in software involves the following operations (shown in pseudo C) to obtain a 4-bit result value, r.The result, r=bpext(x,y)
where,
x=32 bit value containing four packed bytes
y=integer number between 0 and 7 referring to the bit to be extracted
A bit-plane extraction operation may comprise the following operations:
unsigned bpext_big (unsigned x, unsigned y){unsigned t0 = x>>y;return (t0 & 0x00000001) |((t0 & 0x00000100) >> 7) |((t0 & 0x00010000) >> 14) |((t0 & 0x01000000) >> 21);}
The bit-plane extraction operation shown above will now be described in greater detail with reference to FIG. 1. First, in step 101 the value x is shifted over y positions (ie “y” being the numerical number representing the bit to be extracted), such that the bits to be extracted are all at the same location. Then, in step 103, one bit is extracted using an AND operation (for example t0 & 0x00000001 for the first bit). This is repeated, steps 105 to 107, to extract the relevant bit from each of the other bytes until the nth bit is extracted (“n” being four in the example). In step 109 the extracted bits are then shifted to the target bit locations (corresponding to the final positions of the bits in the end result), and ORed together, step 111.
The pixel data may be arranged in “big endian” format or “little endian” format. In the big endian format the bytes are arranged with the most significant byte first, while in the little endian format the bytes are arranged with the least significant byte first. Therefore, depending on the endianness of the pixel data, or indeed for other reasons, it may be desirable to reverse the resulting bits.
An implementation example of how to reverse the bits is shown below:
unsigned bpext_reverse (unsigned x, unsigned y){unsigned r = bpext (x, y);return ((r&1)<<3) | ((r&2)<<1) | ((r&4)>>1) | ((r&8)>>3);}
The instruction code shown above selects individual bits and shifts them to their reversed locations, so that bit 0 becomes bit 3 ((r&1)<<3), bit 1 becomes bit 2 ((r&2)<<1), etc., and these bits are again ORed together.
It is noted that the example above shows how to select just a single bit from packed data. However, more than one bit can also be extracted, for example, selecting two bits per byte or data element, and concatenating these bits into an eight bit result value.
It will be appreciated that, to perform the bit-plane extraction operation described above on a programmable data processor, the bit-plane extraction operation involves the execution of several (non-dedicated) operations. This has disadvantages both in terms of performance and power consumption.
The aim of the present invention is therefore to provide a programmable data processing apparatus having a bit-plane extraction operation that does not have the disadvantages mentioned above.